package com.xzer.xiaozhuoerinterface.controller;

import com.xzer.xiaozhuoerinterface.entity.*;
import com.xzer.xiaozhuoerinterface.service.HelloService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    private final HelloService helloService;

    public HelloController(HelloService helloService) {
        this.helloService = helloService;
    }

    @RequestMapping("/hello")
    public HttpResult Hello() {
        return helloService.Hello();
    }

    @RequestMapping("/upload")
    public HttpResult upload(String name, String sex, String nation, String birth, String idCardNum, String addr,
                             String bankCardNum, String bankName, String bankCardType, String carId, String licenseNum,
                                 String licenseData, String carModel, String carOwner, String driverCardNum, String driverLastData) {
        PerInfo perInfo = new PerInfo();
        perInfo.setAll(name, sex, nation, birth, idCardNum, addr, bankCardNum, bankName, bankCardType, carId, licenseNum,
                        licenseData, carModel, carOwner, driverCardNum, driverLastData);
        return helloService.UpLoad(perInfo);
    }
    @RequestMapping("/uploadIdCardData")
    public HttpResult uploadIdCardData(String name, String fullname, String sex, String nation, String birth, String idCardNum, String addr) {
        Idcardtable idcardtable = new Idcardtable(name,fullname,sex,nation,birth,idCardNum,addr);
        return helloService.InsertIdCardTable(idcardtable);
    }

    @RequestMapping("/getCredit")
    public HttpResult getCredit(String idCardNum) {
        return helloService.getCredit(idCardNum);
    }

    @RequestMapping("/getAllInfo")
    public HttpResult getAllInfo() {
        return helloService.getAllInfo();
    }

    @RequestMapping("/deleteInfoFromId")
    public HttpResult deleteInfoFromId(String idCardNum) {
        return helloService.deleteInfoFromId(idCardNum);
    }

    @RequestMapping("/reg")
    public HttpResult reg(String username, String password) {
        LoginInfo loginInfo = new LoginInfo();
        loginInfo.setUsername(username);
        loginInfo.setPassword(password);
        return helloService.reg(loginInfo);
    }

    @RequestMapping("/login")
    public HttpResult login(String username, String password) {
        LoginInfo loginInfo = new LoginInfo();
        loginInfo.setUsername(username);
        loginInfo.setPassword(password);
        return helloService.login(loginInfo);
    }

    @RequestMapping("/shareBike")
    public HttpResult shareBike(String username,String platType) {
        return helloService.shareBike(username,platType);
    }

    @RequestMapping("/shareCar")
    public HttpResult shareCar(String username,String carType) {
        return helloService.shareCar(username,carType);
    }

    @RequestMapping("/uploadDriverData")
    public HttpResult uploadDriverData(String fullname,String driverCardNum, String driverCode,String lastData) {
        DriverTable driverTable = new DriverTable(fullname,driverCardNum,driverCode,lastData);
        return helloService.uploadDriverData(driverTable);
    }

    @RequestMapping("/cleanDriverData")
    public HttpResult cleanDriverData(String fullname, String credit) {
        return helloService.cleanDriverData(fullname,credit);
    }

    @RequestMapping("/uploadCarData")
    public HttpResult uploadCarData(String carTableJson, String carowner, String credit) {
        return helloService.uploadCarData(carTableJson, carowner, credit);
    }
    @RequestMapping("/selCleanCarData")
    public HttpResult selCleanCarData(String strNum) {
        return helloService.selCleanCarData(strNum);
    }
    @RequestMapping("/cleanCarData")
    public HttpResult cleanCarData(String fullname, String credit) {
        return helloService.cleanCarData(fullname, credit);
    }
    @RequestMapping("/getCarData")
    public HttpResult getCarData(String fullname) {
        return helloService.getCarData(fullname);
    }

    @RequestMapping("/uploadBankCardData")
    public HttpResult uploadBankCardData(String bankCardTableJson, String name, String credit) {
        return helloService.uploadBankCardData(bankCardTableJson, name, credit);
    }
    @RequestMapping("/selCleanBankCardData")
    public HttpResult selCleanBankCardData(String strNum) {
        return helloService.selCleanBankCardData(strNum);
    }

    @RequestMapping("/getBankCardData")
    public HttpResult getBankCardData(String idcardnum) {
        return helloService.getBankCardData(idcardnum);
    }

    @RequestMapping("/getBankCreditSum")
    public HttpResult getBankCreditSum(String idcardnum) {
        return helloService.getBankCreditSum(idcardnum);
    }
}
